package com.micro.frog.acct.rest;

import com.micro.frog.acct.service.UserService;
import com.micro.frog.acct.utils.CacheUtil;
import com.micro.frog.acct.utils.CookieUtil;
import com.micro.frog.core.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author :  ljh
 * @date : 2018/4/9
 **/
@RestController
public class LoginController {

    @Autowired
    UserService userService;

    @PostMapping(value = "/admin/login.do")
    @ResponseBody
    public Result login(String userName, String password, HttpServletRequest request, HttpServletResponse response){
        Result result = new Result();
        try{
            result = userService.login(userName, password, request, response);
        }catch (Exception e){
            e.printStackTrace();
            result.setFlag(false);
            result.setMsg("登录失败");
        }
        return result;
    }

}
